Junit test bluej [closed]

Posted by user1721929 on Programmers See other posts from Programmers or by user1721929
Published on 2012-10-26T11:31:46Z Indexed on 2012/10/26 17:19 UTC
Read the original article Hit count: 360

Filed under:
|

Can someone make a junit test of this?

public class PersonName {

int NumberNames(String wholename)
{    // store the name passed in to the method
    String testname=wholename;
     // initialize number of names found
    int numnames=0;
     // on each iteration remove one name
     while(testname.length()>numnames)
    {   // take the "white space" from the beginning and end
       testname = testname.trim();
        // determine the position of the first blank
        // .. end of the first word
       int posBlank= testname.indexOf(' ');
      // cut off word
      /**
       * it continues to the stop sign because that is where you commanded it to end
       */
       testname=testname.substring(posBlank+1,testname.length());
      //  System.out.println(numnames);
      // System.out.println(testname);
       numnames++;
       System.out.println(testname);
    }    
    return numnames;
}


public static void main(String args[])
{
    PersonName One= new PersonName();

    System.out.println(One.NumberNames("Bobby"));
    System.out.println(One.NumberNames("Bobby Smith"));
    System.out.println(One.NumberNames("Bobby L. Smith"));
    System.out.println(One.NumberNames("  Bobby  Paul Smith Jr.  "));



}

}

© Programmers or respective owner

Related posts about java

Related posts about junit